
# -*- coding: utf-8 -*-

import logging
import numpy
from PIL import Image
import StringIO
from tornado.websocket import WebSocketHandler

class BaseSocketController(WebSocketHandler):
	def open(self):
		logging.info('Connection opened')

	def on_message(self, message):
		image = Image.open(StringIO.StringIO(message))
		cv_image = numpy.array(image)
		self.process(cv_image)

	def on_close(self):
		logging.info('Connection closed')

	def process(self, cv_image):
		pass
